home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Games 1996 July
/
Amiga Games 1996 #7.iso
/
archive
/
userbox
/
publicdomain
/
muispell.lha
/
MUISpell
/
Source
/
Gui.c
< prev
next >
Wrap
C/C++ Source or Header
|
1996-03-28
|
19KB
|
537 lines
/***************************************************************************
* *
* MUISpell *
* Spellchecking without texteditor, requires AlphaSpell and MUI *
* Copyright (C) 1996 Dirk Holtwick *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the Free Software *
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
* *
* Author: Dirk Holtwick *
* Karlstr. 59 *
* 47119 Duisburg *
* GERMANY *
* dirco@uni-duisburg.de *
* *
****************************************************************************/
// The first source has been genereate with MUIBuilder, but then I had
// some problems with it and startet to change things by hand.
// But anyway MUIBuilder is a fantastic program!
#ifndef MAKE_ID
#define MAKE_ID(a,b,c,d) ((ULONG) (a)<<24 | (ULONG) (b)<<16 | (ULONG) (c)<<8 | (ULONG) (d))
#endif
#ifdef _DCC
#define __inline
#endif
enum{
p_,
p_ram,
p_backward,
p_forward,
p_path,
p_dict,
p_keyfile,
p_rate,
p_user,
p_buffer,
p_command
};
#include <clib/asl_protos.h>
#include "Gui.h"
#include "GuiExtern.h"
#include "Cat.h"
#include <clib/gadtools_protos.h>
#define Barlabel MUIA_Family_Child,MenuitemObject,MUIA_Menuitem_Title,NM_BARLABEL,End
extern STRPTR GetMUISpellString(LONG);
static char *GetMBString(int ref)
{
char *aux;
aux = GetMUISpellString(ref);
if (aux[1] == '\0') return(&aux[2]);
else return(aux);
}
struct ObjApp * CreateApp(void)
{
struct ObjApp * Object;
APTR MNlabel0Projekt, MNlabel0Laden, MNlabel0Speichern, MNlabel0Speichernals;
APTR MNlabel0Voreinstellungen, menspellHilfe, MNlabel0Info, MNlabel0Ende;
APTR gr_view, gr_prefs, gr_prefs_2, la_back, la_forward;
APTR GR_grp_5, la_path, la_books, la_keyfile, la_rate, GR_grp_3;
APTR la_user, la_buffer, la_command;
static const struct Hook do_learnHook = { { NULL,NULL },(VOID *)do_learn,NULL,NULL };
static const struct Hook do_goonHook = { { NULL,NULL },(VOID *)do_goon,NULL,NULL };
static const struct Hook do_backHook = { { NULL,NULL },(VOID *)do_back,NULL,NULL };
static const struct Hook do_lvacceptHook = { { NULL,NULL },(VOID *)do_lvaccept,NULL,NULL };
static const struct Hook do_loadHook = { { NULL,NULL },(VOID *)do_load,NULL,NULL };
static const struct Hook do_saveHook = { { NULL,NULL },(VOID *)do_save,NULL,NULL };
static const struct Hook do_saveasHook = { { NULL,NULL },(VOID *)do_saveas,NULL,NULL };
static const struct Hook do_guessHook = { { NULL,NULL },(VOID *)do_guess,NULL,NULL };
static const struct Hook do_acceptHook = { { NULL,NULL },(VOID *)do_accept,NULL,NULL };
static const struct Hook do_save_prefsHook = { { NULL,NULL },(VOID *)do_save_prefs,NULL,NULL };
static const struct Hook do_use_prefsHook = { { NULL,NULL },(VOID *)do_use_prefs,NULL,NULL };
static const struct Hook do_cancel_prefsHook = { { NULL,NULL },(VOID *)do_cancel_prefs,NULL,NULL };
static const struct Hook do_ignoreHook = { { NULL,NULL },(VOID *)do_ignore,NULL,NULL };
static const struct Hook do_editdistHook = { { NULL,NULL },(VOID *)do_editdist,NULL,NULL };
static const struct Hook do_booksHook = { { NULL,NULL },(VOID *)do_books,NULL,NULL };
static const struct Hook do_bookstartHook = { { NULL,NULL },(VOID *)do_bookstart,NULL,NULL };
static const struct Hook do_drawerHook = { { NULL,NULL },(VOID *)do_drawer,NULL,NULL };
static const struct Hook do_lineHook = { { NULL,NULL },(VOID *)do_line,NULL,NULL };
static const struct Hook do_popupHook = { { NULL,NULL },(VOID *)do_popup,NULL,NULL };
if (!(Object = AllocVec(sizeof(struct ObjApp), MEMF_PUBLIC|MEMF_CLEAR)))
return(NULL);
Object->STR_txt_view = NULL;
Object->cy_ramContent[0] = GetMBString(m_cy_ram0);
Object->cy_ramContent[1] = GetMBString(m_cy_ram1);
Object->cy_ramContent[2] = GetMBString(m_cy_ram2);
Object->cy_ramContent[3] = GetMBString(m_cy_ram3);
Object->cy_ramContent[4] = NULL;
Object->cy_lineContent[0] = GetMBString(m_cy_line0);
Object->cy_lineContent[1] = GetMBString(m_cy_line1);
Object->cy_lineContent[2] = NULL;
Object->win_view = WindowObject,
MUIA_Window_Title, "MUISpell 1.1 © Dirk Holtwick 1995",
MUIA_Window_ID, MAKE_ID('1', 'W', 'I', 'N'),
WindowContents, gr_view = GroupObject,
Child, HGroup,
Child, Object->bt_tback = SimpleButton(GetMBString(m_bt_back)),
Child, Object->pa_spell = PopobjectObject,
MUIA_Weight, 1000,
MUIA_Popobject_WindowHook, &do_popupHook,
MUIA_Popstring_String, Object->str_spell = StringObject,
MUIA_ControlChar, ' ',
MUIA_Frame, MUIV_Frame_String,
MUIA_String_Format, MUIV_String_Format_Center,
MUIA_ShortHelp, "Geben sie für das fehlerhafte\nWort die Korrektur an.",
End,
MUIA_Popstring_Button, PopButton(MUII_PopUp),
MUIA_Popobject_Object, Object->lv_spell = ListviewObject,
MUIA_Listview_DoubleClick, TRUE,
MUIA_Listview_List, ListObject,
MUIA_Frame, MUIV_Frame_InputList,
MUIA_List_Format, "P=\033c",
End,
End,
End,
Child, Object->bt_tskip = SimpleButton(GetMBString(m_bt_skip)),
End,
Child, Object->lv_view = ListviewObject,
MUIA_Listview_Input, FALSE,
MUIA_Listview_List, FloattextObject,
MUIA_Frame, MUIV_Frame_ReadList,
End,
End,
Child, Object->gauge_txt=GaugeObject,
GaugeFrame,
MUIA_Gauge_Horiz, TRUE,
MUIA_Gauge_Current, 0,
MUIA_FixHeightTxt, "X",
End,
Child, HGroup,
MUIA_Group_SameSize, TRUE,
Child, Object->bt_learn = SimpleButton(GetMBString(m_bt_learn)),
Child, Object->bt_guess = SimpleButton(GetMBString(m_bt_guess)),
Child, Object->cy_line = CycleObject,
MUIA_ControlChar, '/',
MUIA_Cycle_Entries, Object->cy_lineContent,
MUIA_ShortHelp, "Wollen sie nur ein Wort\noder eine ganze Zeile\nkorrigieren?",
End,
Child, Object->bt_accept = SimpleButton(GetMBString(m_bt_accept)),
Child, Object->bt_ignore = SimpleButton(GetMBString(m_bt_ignore)),
End,
End,
End;
Object->cy_ram = CycleObject,
MUIA_ExportID, p_ram,
MUIA_Cycle_Entries, Object->cy_ramContent,
MUIA_ShortHelp, "Sollen die Wörterbücher und\ndas Programm in die RAM Disk\numgelagert werden?",
End;
Object->sl_back = SliderObject,
MUIA_ExportID, p_backward,
MUIA_Slider_Min, 1,
MUIA_Slider_Max, 50,
MUIA_Slider_Level, 5,
MUIA_ShortHelp, "Wieviele Zeilen sollen vor\ndem fehlerhaften Wort\nangezeigt werden?",
End;
la_back = LLabel(GetMBString(m_la_back));
Object->sl_forward = SliderObject,
MUIA_ExportID, p_forward,
MUIA_Slider_Min, 1,
MUIA_Slider_Max, 50,
MUIA_Slider_Level, 5,
MUIA_ShortHelp, "Wieviele Zeilen sollen hinter\ndem fehlerhaften Wort\nangezeigt werden?",
End;
la_forward = LLabel(GetMBString(m_la_forward));
la_buffer = LLabel(GetMBString(m_la_buffer));
Object->sl_buffer = SliderObject,
MUIA_ExportID, p_buffer,
MUIA_Slider_Min, 5,
MUIA_Slider_Max, 99,
MUIA_Slider_Level, 20,
MUIA_ShortHelp, "Wieviel Prozent zu der Textlänge\nsollen als Arbeitsspeicher\nreserviert werden?",
End;
gr_prefs_2 = GroupObject,
MUIA_Background, MUII_GroupBack,
MUIA_Frame, MUIV_Frame_Group,
MUIA_FrameTitle, GetMBString(m_gr_prefs_2Title),
MUIA_Group_Columns, 2,
Child, la_back,
Child, Object->sl_back,
Child, la_forward,
Child, Object->sl_forward,
Child, la_buffer,
Child, Object->sl_buffer,
End;
la_path = LLabel(GetMBString(m_la_path));
Object->str_drawer = StringObject,
MUIA_ExportID, p_path,
MUIA_Frame, MUIV_Frame_String,
MUIA_String_Contents, "work:dictionary/",
MUIA_ShortHelp, "In welchem Verzeichnis\nbefinden sich ihre\nWörterbücher?",
End;
Object->pa_drawer = PopaslObject,
MUIA_Popstring_String, Object->str_drawer,
MUIA_Popstring_Button, PopButton(MUII_PopDrawer),
ASLFR_DrawersOnly, TRUE,
End;
la_books = LLabel(GetMBString(m_la_books));
Object->str_books = StringObject,
MUIA_ExportID, p_dict,
MUIA_Frame, MUIV_Frame_String,
MUIA_String_Contents, "*.low *.mix",
MUIA_String_MaxLen, 200,
End;
Object->pa_books = PopaslObject,
MUIA_Popasl_StopHook, &do_booksHook,
MUIA_Popasl_StartHook, &do_bookstartHook,
MUIA_Popstring_String, Object->str_books,
MUIA_Popstring_Button, PopButton(MUII_PopFile),
ASLFR_DoMultiSelect, TRUE,
ASLFR_InitialFile, "",
ASLFR_DoPatterns, TRUE,
ASLFR_InitialPattern,"#?.(mix|low)",
End;
la_user = LLabel(GetMBString(m_la_user));
Object->str_user = StringObject,
MUIA_ExportID, p_user,
MUIA_Frame, MUIV_Frame_String,
MUIA_String_Contents, "User",
MUIA_String_MaxLen, 200,
End;
la_keyfile = LLabel(GetMBString(m_la_keyfile));
Object->str_keyfile = StringObject,
MUIA_ExportID, p_keyfile,
MUIA_Frame, MUIV_Frame_String,
MUIA_String_Contents, "S:Alpha-Key",
MUIA_String_MaxLen, 80,
End;
Object->pa_keyfile = PopaslObject,
MUIA_Popstring_String, Object->str_keyfile,
MUIA_Popstring_Button, PopButton(MUII_PopFile),
End;
la_command = LLabel("AlphaSpell");
Object->str_command = StringObject,
MUIA_ExportID, p_command,
MUIA_Frame, MUIV_Frame_String,
MUIA_String_Contents, "C:ASpell",
MUIA_String_MaxLen, 80,
End;
Object->pa_command = PopaslObject,
MUIA_Popstring_String, Object->str_command,
MUIA_Popstring_Button, PopButton(MUII_PopFile),
End;
la_rate = LLabel(GetMBString(m_la_rate));
Object->sl_rate = SliderObject,
MUIA_ExportID, p_rate,
MUIA_Slider_Min, 0,
MUIA_Slider_Max, 20,
MUIA_Slider_Level, 2,
End;
GR_grp_5 = GroupObject,
MUIA_Background, MUII_GroupBack,
MUIA_Frame, MUIV_Frame_Group,
MUIA_FrameTitle, GetMBString(m_GR_grp_5Title),
MUIA_Group_Columns, 2,
Child, la_path,
Child, Object->pa_drawer,
Child, la_books,
Child, Object->pa_books,
Child, la_user,
Child, Object->str_user,
Child, la_command,
Child, Object->pa_command,
Child, la_keyfile,
Child, Object->pa_keyfile,
Child, la_rate,
Child, Object->sl_rate,
End;
Object->bt_save_prefs = SimpleButton(GetMBString(m_bt_save_prefs));
Object->bt_use_prefs = SimpleButton(GetMBString(m_bt_use_prefs));
Object->bt_cancel_prefs = SimpleButton(GetMBString(m_bt_cancel_prefs));
GR_grp_3 = GroupObject,
MUIA_Group_Horiz, TRUE,
MUIA_Group_SameSize, TRUE,
Child, Object->bt_save_prefs,
Child, Object->bt_use_prefs,
Child, Object->bt_cancel_prefs,
End;
gr_prefs = GroupObject,
Child, Object->cy_ram,
Child, gr_prefs_2,
Child, GR_grp_5,
Child, GR_grp_3,
End;
Object->win_prefs = WindowObject,
MUIA_Window_Title, GetMBString(m_win_prefs),
MUIA_Window_ID, MAKE_ID('2', 'W', 'I', 'N'),
MUIA_Window_NoMenus, TRUE,
WindowContents, gr_prefs,
End;
// WINDOW INFO
Object->win_info = WindowObject,
MUIA_Window_Title, GetMBString(m_win_info),
MUIA_Window_ID, MAKE_ID('3', 'W', 'I', 'N'),
MUIA_Window_CloseGadget, FALSE,
MUIA_Window_NoMenus, TRUE,
WindowContents, GroupObject,
Child, HGroup,
MUIA_Background, MUII_GroupBack,
MUIA_Frame, MUIV_Frame_Group,
Child, VGroup,
Child, ImageObject,
MUIA_Background, MUII_GroupBack,
MUIA_Image_Spec, "5:MUISpell.brush",
MUIA_FramePhantomHoriz, TRUE,
MUIA_Frame, MUIV_Frame_ImageButton,
MUIA_Image_FreeVert, TRUE,
MUIA_Image_FreeHoriz, TRUE,
MUIA_FixWidth, 97,
MUIA_FixHeight, 103,
End,
Child, VSpace(0),
End,
Child, ListviewObject,
MUIA_Weight, 250,
MUIA_Listview_Input, FALSE,
MUIA_Listview_List, FloattextObject,
MUIA_Background, MUII_GroupBack,
MUIA_List_Format, "P=\33c",
MUIA_Floattext_Text, GetMBString(m_tx_info),
End,
End,
End,
Child, Object->bt_info = SimpleButton(GetMBString(m_bt_info)),
End,
End;
// MENU
Object->men_spell = MenustripObject,
MUIA_Family_Child, MNlabel0Projekt = MenuitemObject,
MUIA_Menuitem_Title, GetMBString(m_MNlabel0Projekt),
MUIA_Family_Child, MNlabel0Laden = MenuitemObject,
MUIA_Menuitem_Title, GetMBString(m_MNlabel0Laden),
MUIA_Menuitem_Shortcut, GetMBString(m_MNlabel0LadenChar),
End,
Barlabel,
MUIA_Family_Child, MNlabel0Speichern = MenuitemObject,
MUIA_Menuitem_Title, GetMBString(m_MNlabel0Speichern),
MUIA_Menuitem_Shortcut, GetMBString(m_MNlabel0SpeichernChar),
End,
MUIA_Family_Child, MNlabel0Speichernals = MenuitemObject,
MUIA_Menuitem_Title, GetMBString(m_MNlabel0Speichernals),
MUIA_Menuitem_Shortcut, GetMBString(m_MNlabel0SpeichernalsChar),
End,
Barlabel,
MUIA_Family_Child, MNlabel0Voreinstellungen = MenuitemObject,
MUIA_Menuitem_Title, GetMBString(m_MNlabel0Voreinstellungen),
MUIA_Menuitem_Shortcut, GetMBString(m_pref),
End,
Barlabel,
MUIA_Family_Child, menspellHilfe = MenuitemObject,
MUIA_Menuitem_Title, GetMBString(m_menspellHilfe),
End,
MUIA_Family_Child, MNlabel0Info = MenuitemObject,
MUIA_Menuitem_Title, GetMBString(m_MNlabel0Info),
End,
Barlabel,
MUIA_Family_Child, MNlabel0Ende = MenuitemObject,
MUIA_Menuitem_Title, GetMBString(m_MNlabel0Ende),
MUIA_Menuitem_Shortcut, GetMBString(m_MNlabel0EndeChar),
End,
End,
End;
// APPLICATION
Object->App = ApplicationObject,
MUIA_Application_Author, "Dirk Holtwick",
MUIA_Application_Menustrip, Object->men_spell,
MUIA_Application_Base, "MUISPELL",
MUIA_Application_Title, "MUISpell",
MUIA_Application_Version, "$VER: MUISpell 1.1 [" __DATE__ "]",
MUIA_Application_Copyright, "© Dirk Holtwick 1995/1996",
MUIA_Application_Description, GetMBString(m_AppDescription),
MUIA_Application_HelpFile, GetMBString(m_guide),
MUIA_HelpNode, "Main",
SubWindow, Object->win_view,
SubWindow, Object->win_prefs,
SubWindow, Object->win_info,
End;
if (!Object->App){
FreeVec(Object);
return(NULL);
}
// METHODS
DoMethod(MNlabel0Laden,MUIM_Notify, MUIA_Menuitem_Trigger, MUIV_EveryTime,
MNlabel0Laden,2,MUIM_CallHook, &do_loadHook);
DoMethod(MNlabel0Speichern,MUIM_Notify, MUIA_Menuitem_Trigger, MUIV_EveryTime,
MNlabel0Speichern,2, MUIM_CallHook, &do_saveHook);
DoMethod(MNlabel0Speichernals,MUIM_Notify, MUIA_Menuitem_Trigger, MUIV_EveryTime,
MNlabel0Speichernals,2, MUIM_CallHook, &do_saveasHook);
DoMethod(MNlabel0Voreinstellungen,MUIM_Notify, MUIA_Menuitem_Trigger, MUIV_EveryTime,
Object->win_prefs,3,MUIM_Set, MUIA_Window_Open, TRUE);
DoMethod(menspellHilfe, MUIM_Notify, MUIA_Menuitem_Trigger, MUIV_EveryTime,
Object->App,5,MUIM_Application_ShowHelp,0,GetMBString(m_guide),"Main",0);
DoMethod(MNlabel0Info,MUIM_Notify, MUIA_Menuitem_Trigger, MUIV_EveryTime,
Object->win_info,3,MUIM_Set, MUIA_Window_Open, TRUE);
DoMethod(MNlabel0Ende,MUIM_Notify, MUIA_Menuitem_Trigger, MUIV_EveryTime,
Object->App,2,MUIM_Application_ReturnID, MUIV_Application_ReturnID_Quit);
DoMethod(Object->lv_spell,MUIM_Notify, MUIA_Listview_DoubleClick, TRUE,
Object->lv_spell,2,MUIM_CallHook, &do_lvacceptHook );
DoMethod(Object->bt_learn, MUIM_Notify, MUIA_Pressed, FALSE,
Object->bt_learn,2,MUIM_CallHook, &do_learnHook);
DoMethod(Object->bt_guess,MUIM_Notify, MUIA_Pressed, FALSE,
Object->bt_guess,2,MUIM_CallHook, &do_guessHook);
DoMethod(Object->cy_line,MUIM_Notify, MUIA_Cycle_Active, MUIV_EveryTime,
Object->cy_line,2,MUIM_CallHook, &do_lineHook);
DoMethod(Object->bt_accept,MUIM_Notify, MUIA_Pressed, FALSE,
Object->bt_accept,2,MUIM_CallHook, &do_acceptHook);
DoMethod(Object->bt_ignore,MUIM_Notify, MUIA_Pressed, FALSE,
Object->bt_ignore,2,MUIM_CallHook, &do_ignoreHook);
DoMethod(Object->bt_tskip,MUIM_Notify, MUIA_Pressed, FALSE,
Object->bt_tskip,2,MUIM_CallHook, &do_goonHook);
DoMethod(Object->bt_tback,MUIM_Notify, MUIA_Pressed, FALSE,
Object->bt_tback,2,MUIM_CallHook, &do_backHook);
DoMethod(Object->win_view,MUIM_Notify, MUIA_Window_CloseRequest, TRUE,
Object->App,2,MUIM_Application_ReturnID, MUIV_Application_ReturnID_Quit);
DoMethod(Object->win_view,MUIM_Window_SetCycleChain,
Object->lv_view,0);
DoMethod(Object->win_prefs,MUIM_Notify, MUIA_Window_CloseRequest, TRUE,
Object->win_prefs,3,MUIM_Set, MUIA_Window_Open, FALSE);
DoMethod(Object->bt_save_prefs,MUIM_Notify, MUIA_Pressed, FALSE,
Object->bt_save_prefs,2,MUIM_CallHook, &do_save_prefsHook);
DoMethod(Object->bt_use_prefs,MUIM_Notify, MUIA_Pressed, FALSE,
Object->bt_use_prefs,2,MUIM_CallHook, &do_use_prefsHook);
DoMethod(Object->bt_cancel_prefs,MUIM_Notify, MUIA_Pressed, FALSE,
Object->bt_cancel_prefs,2,MUIM_CallHook, &do_cancel_prefsHook);
DoMethod(Object->str_keyfile,MUIM_Notify, MUIA_String_Acknowledge, MUIV_EveryTime,
Object->str_keyfile,2,MUIM_CallHook, &do_editdistHook);
DoMethod(Object->str_drawer,MUIM_Notify, MUIA_String_Acknowledge, MUIV_EveryTime,
Object->str_drawer,2,MUIM_CallHook, &do_drawerHook);
DoMethod(Object->str_spell, MUIM_Notify, MUIA_String_Acknowledge, MUIV_EveryTime,
Object->str_spell,2,MUIM_CallHook, &do_acceptHook);
DoMethod(Object->bt_info,MUIM_Notify, MUIA_Pressed, FALSE,
Object->win_info,3,MUIM_Set, MUIA_Window_Open, FALSE);
DoMethod(Object->win_info,MUIM_Window_SetCycleChain,
Object->bt_info,0);
DoMethod(Object->win_prefs,
MUIM_Window_SetCycleChain, Object->cy_ram,
Object->sl_back,
Object->sl_forward,
Object->sl_buffer,
Object->pa_drawer,
Object->pa_books,
Object->str_user,
Object->pa_keyfile,
Object->sl_rate,
Object->bt_save_prefs,
Object->bt_use_prefs,
Object->bt_cancel_prefs,
0);
DoMethod(Object->win_view,
MUIM_Window_SetCycleChain,
Object->bt_tback,
Object->pa_spell,
Object->bt_tskip,
Object->lv_view,
Object->bt_learn,
Object->bt_guess,
Object->cy_line,
Object->bt_accept,
Object->bt_ignore,
0);
set(Object->win_view, MUIA_Window_Open, TRUE);
return(Object);
}
void DisposeApp(struct ObjApp * Object)
{
MUI_DisposeObject(Object->App);
FreeVec(Object);
}